package com.liuwei.spring.cloud.common.utils.feishu.message;/**
 * @author : ImageMessage
 * @version V1.0
 * @date: 2023/12/29 4:02 PM
 * @Description: TODO
 */

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.liuwei.spring.cloud.common.utils.Jackson;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

/**
 * @author : ImageMessage
 * @version V1.0
 * @date: 2023/12/29 4:02 PM
 * @Description: TODO
 */
@Slf4j
@Data
public class ImageMessage extends BaseFeishuMessage{

    /**
     * {
     *     "msg_type":"image",
     *     "content":{
     *         "image_key": "img_ecffc3b9-8f14-400f-a014-05eca1a4310g"
     *     }
     * }
     */
    @JsonProperty("msg_type")
    private String messageType = "image";

    private ImageMessage.MessageContent content;

    @Data
    public static class MessageContent{
        @JsonProperty("image_key")
        private String imageKey;
    }

    public static ImageMessage buildImageMessage(String feishuImageKey){
        MessageContent content = new MessageContent();
        content.setImageKey(feishuImageKey);

        ImageMessage message = new ImageMessage();
        message.setContent(content);
        return message;
    }

    @Data
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class CodeMessage{
        private String code;
        private String msg;
    }

    @Data
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class UploadResponse{
        private String code;
        private ImageData data;
        private String msg;
    }

    @Data
    public static class ImageData{
        @JsonProperty("image_key")
        private String key;
    }
}
